<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>axios常用配置以及默认配置</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>
<body>
    <button>获取英雄联盟的英雄</button>
    <button>获取王者荣耀的英雄</button>
    <button>本地服务</button>
    <script>
        // abc.xiaohigh.com
        let btns = document.querySelectorAll('button');

        //设置 baseURL 的值
        axios.defaults.baseURL = 'http://api.xiaohigh.com';
        axios.defaults.timeout = 2000;


        btns[0].onclick = async function(){
            let result = await axios.get('/lol');
            console.log(result);
        }

        btns[1].onclick = async function(){
            let result = await axios.get('/heros');
            console.log(result);
        }

        btns[2].onclick = async function(){
            let result = await axios.get('http://127.0.0.1:8090/server');
            console.log(result);
        }
    </script>
</body>
</html>